﻿using System.Collections;
using DVDTek_Data_Object.DataObject;

namespace DVDTek_Data_Object.Collection
{
    public class VideoCollection
    {
        #region Members
        private ArrayList videos = new ArrayList();

        public int Count
        {
            get { return this.videos.Count; }
        }

        public VideoDataObject this[int i]
        {
            get
            {
                return (VideoDataObject)this.videos[i];
            }
            set
            {
                if (value == null)
                    RemoveAt(i);
                else
                    this.videos[i] = value;
            }
        }
        #endregion

        #region Constructors
        public VideoCollection()
        {
        }
        #endregion

        #region Functions
        public void Add(VideoDataObject item)
        {
            this.videos.Add(item);
        }

        public void Clear()
        {
            this.videos.Clear();
        }

        public bool Contains(VideoDataObject item)
        {
            return this.videos.Contains(item);
        }

        #region IndexOf
        public int IndexOf(VideoDataObject item)
        {
            return this.videos.IndexOf(item);
        }

        public int IndexOf(VideoDataObject item, int startIndex)
        {
            return this.videos.IndexOf(item, startIndex);
        }

        public int IndexOf(VideoDataObject item, int startIndex, int count)
        {
            return this.videos.IndexOf(item, startIndex, count);
        }
        #endregion

        public void Insert(int index, VideoDataObject value)
        {
            this.videos.Insert(index, value);
        }

        #region LastIndexOf
        public int LastIndexOf(VideoDataObject value)
        {
            return this.videos.LastIndexOf(value);
        }

        public int LastIndexOf(VideoDataObject value, int startIndex)
        {
            return this.videos.LastIndexOf(value, startIndex);
        }

        public int LastIndexOf(VideoDataObject value, int startIndex, int count)
        {
            return this.videos.LastIndexOf(value, startIndex, count);
        }
        #endregion

        #region Remove
        public bool Remove(VideoDataObject item)
        {
            int index = this.videos.IndexOf(item);
            if (index >= 0)
            {
                this.videos.RemoveAt(index);
                return true;
            }
            else
                return false;
        }

        public void RemoveAt(int i)
        {
            this.videos.RemoveAt(i);
        }

        public void RemoveRange(int index, int count)
        {
            this.videos.RemoveRange(index, count);
        }
        #endregion

        #region Reverse
        public void Reverse()
        {
            this.videos.Reverse();
        }

        public void Reverse(int index, int count)
        {
            this.videos.Reverse(index, count);
        }
        #endregion

        #region Sort
        #endregion

        public VideoDataObject[] ToArray()
        {
            VideoDataObject[] array = new VideoDataObject[Count];
            for (int i = 0; i < Count; i++)
                array[i] = this[i];
            return array;
        }

        public void TrimToSize()
        {
            this.videos.TrimToSize();
        }
        #endregion
    }
}
